//
// Created by heming on 4/27/20.
//

#ifndef TRY_HYPERSCAN_UNIT_H
#define TRY_HYPERSCAN_UNIT_H

#include <vector>
#include <string>

struct Match{
    int id;
    long long startPosition;
    long long endPosition;
    std::string matchedString;
};

struct MatchRecord {
    MatchRecord(unsigned long long f,unsigned long long t, int i) : from(f), to(t), id(i) {}
    bool operator==(const MatchRecord &o) const {
        return  from == o.from && to == o.to && id == o.id;
    }
    unsigned long long from;
    unsigned long long to;
    int id;
};

struct CallBackContext {
    bool halt = false;
    std::vector<MatchRecord> matches;

    void clear() {
        halt = false;
        matches.clear();
    }
};

 void parseFile(const char *filename, std::vector<std::string> &patterns,
                      std::vector<unsigned> &flags, std::vector<unsigned> &ids);

 char *readInputData(const char *inputFN, unsigned int *length);

std::string& trim(std::string &s);

int record_cb(unsigned id, unsigned long long from, unsigned long long to,
              unsigned, void *ctxt);

static unsigned parseFlags(const std::string &flagsStr);


#endif //TRY_HYPERSCAN_UNIT_H
